Skip to content

fix(sonar): handle app.whenReady rejection on startup (typescript:S9383) - #3380

Merged
setchy merged 2 commits into
mainfrom
sonar/S9383-whenready-catch
Oct 4, 2026
Merged

setchy merged 2 commits into
mainfrom
sonar/S9383-whenready-catch

Conversation

@setchy

@setchy setchy commented Oct 4, 2026

Copy link
Copy Markdown
Member

Summary

typescript:S9383 — the module-level startup promise chain in src/main/index.ts used a bare void app.whenReady().then(...), which leaves any rejection unhandled in the main process.

If onFirstRunMaybe() rejects (it awaits dialog.showMessageBox() and app.moveToApplicationsFolder()), or any register*Handlers/initializeAppLifecycle/configureWindowEvents call throws, the rejection goes unhandled: the error skips the app logger, remaining IPC/tray handlers silently never register, and depending on Node's unhandled-rejection mode the app can crash.

This is the same pattern Gitar flagged on the parallel atlassify PR (#setchy/atlassify#3793) and matches the .catch + toError convention already used across gitify's menu.ts, updater.ts, and utils.ts.

Changes

  • src/main/index.ts: replaced bare void app.whenReady().then(...) with a .catch handler that logs via logError('main', 'Failed to initialize application', toError(err)); added the logError/toError import.
  • src/main/index.test.ts (new): covers the menubar config, ozone-before-ready ordering, and the new rejection path (logs an error when whenReady rejects).

Verification

  • pnpm test — 1838/1838 passing (185 files)
  • pnpm exec tsc --noEmit — clean
  • pnpm exec vp lint — clean

Sonar issues: https://sonarcloud.io/project/issues?id=gitify-app_gitify&rules=typescript%3AS9383&issueStatuses=OPEN%2CCONFIRMED

Replace the bare 'void' on the app.whenReady().then(...) startup chain
with a .catch handler that logs startup failures via electron-log. A
rejection in onFirstRunMaybe() (which awaits dialog.showMessageBox) or
any register*/initialize handler would otherwise be left unhandled in
the main process, silently skipping IPC handler registration or
crashing the app depending on Node's unhandled-rejection mode.
@setchy
setchy requested a review from afonsojramos as a code owner October 4, 2026 21:16
@github-actions github-actions Bot added the bug Something isn't working label Oct 4, 2026
@setchy
setchy merged commit 50d7311 into main Oct 4, 2026
14 checks passed
@setchy
setchy deleted the sonar/S9383-whenready-catch branch October 4, 2026 21:18
@github-actions github-actions Bot added this to the Release 7.9.1 milestone Oct 4, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 4, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

1 participant